/*            Copyright(c) 2006-2008 Dave Sexton           *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.XPath;
using System.Collections.ObjectModel;

namespace DaveSexton.DocProject.Sandcastle.TopicManagement
{
	public sealed class NamespaceConfigNode : ApiFilterConfigNode
	{
		#region Public Properties
		public ICollection<TypeConfigNode> Types
		{
			get
			{
				return new ReadOnlyCollection<TypeConfigNode>(types);
			}
		}

		public TypeConfigNode this[string type]
		{
			get
			{
				return types[type];
			}
		}

		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1023:IndexersShouldNotBeMultidimensional")]
		public MemberConfigNode this[string type, string member]
		{
			get
			{
				TypeConfigNode node = types[type];

				if (node == null)
					return null;
				else
					return node[member];
			}
		}
		#endregion

		#region Private / Protected
		private readonly ApiFilterConfigNodeCollection<TypeConfigNode> types = new ApiFilterConfigNodeCollection<TypeConfigNode>();
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="NamespaceConfigNode" /> class and adds it to the specified <paramref name="apiFilter" /> node in the xml document.
		/// </summary>
		internal NamespaceConfigNode(XPathNavigator apiFilter, string name, bool expose)
			: base("namespace", apiFilter, TopicType.Namespace, name, expose)
		{
			if (apiFilter == null)
				throw new ArgumentNullException("apiFilter");
		}

		/// <summary>
		/// Constructs a new instance of the <see cref="NamespaceConfigNode" /> class for the specified <paramref name="node" />.
		/// </summary>
		internal NamespaceConfigNode(XPathNavigator node)
			: base(node, TopicType.Namespace)
		{
		}
		#endregion

		#region Methods
		internal void AddType(TypeConfigNode type)
		{
			types.Add(type);
		}
		#endregion
	}
}
